package controller.menuiconbar;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import view.MainFrame;

public class CopyNameListener implements ActionListener {
	
	public CopyNameListener(MainFrame f) {
		frame = f;
	}
	
	@Override
	public void actionPerformed(ActionEvent arg0) {
		File file = frame.getMainPanel().getPrimary().getDiskContent().getSelectedFile();
		setClipboardContents(file.getAbsolutePath());
	}
	
	 public void setClipboardContents( String aString ){
	    StringSelection stringSelection = new StringSelection( aString );
	    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
	    clipboard.setContents( stringSelection, null );	    
	 }
	
	private MainFrame frame;

}
